package com.huawei.appmarket.service.appdetail.view.fragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appmarket.service.appdetail.view.AppRecommendFragmentProtocol;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.cip;
import o.ciz;
import o.cjk;
import o.cjm;
import o.cjo;
import o.djc;
import o.Logger;
import o.doo;
import o.ead;
import o.ebt;
import o.epv;
import o.evk;
import o.ewm.h;
import o.ewm.n;

public class AppRecommendFragment<T extends AppRecommendFragmentProtocol> extends AppListFragment<AppRecommendFragmentProtocol> implements ciz {
    private String ˊ;

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        AppRecommendFragmentProtocol appRecommendFragmentProtocol = (AppRecommendFragmentProtocol) ˆ();
        if (!(appRecommendFragmentProtocol == null || appRecommendFragmentProtocol.ˏ() == null)) {
            e ˏ = appRecommendFragmentProtocol.ˏ();
            this.ˊʼ = ˏ.ʻ();
            this.ˊ = ˏ.ᐝ();
        }
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        ˊʻ();
        return ˋ;
    }

    public void ˋ(ViewGroup viewGroup, LayoutInflater layoutInflater) {
        super.ˋ(viewGroup, layoutInflater);
        this.ͺˎ.setInterceptScrollOnTop(true);
    }

    public int ߵ() {
        return h.ॱᐝ;
    }

    public void ॱ(Activity activity) {
        super.ॱ(activity);
        ˎ(null);
    }

    public void ᐝ(int i) {
    }

    public void ՙ() {
    }

    private void ˊʻ() {
        if (this.ߴ != null && this.ͺˏ == 1 && this.ˊ != null && this.ˋʻ != null) {
            CSSRule rule = new CSSSelector(this.ˋʻ).getRule(CSSStyleSheet.parse(this.ˊ).getRootRule());
            if (rule != null) {
                CSSView.wrap(this.ߴ, rule).render();
            }
        }
    }

    public void ˋʻ() {
        if (this.ͺˏ == 1 && this.ͺˎ.ˊॱ() != null && this.ˊ != null && this.ˋʻ != null) {
            CSSSelector cSSSelector = new CSSSelector(this.ˋʻ);
            CSSStyleSheet parse = CSSStyleSheet.parse(this.ˊ);
            if (parse != null) {
                CSSRule rule = cSSSelector.getRule(parse.getRootRule());
                if (rule != null) {
                    CSSView.wrap(this.ͺˎ.ˊॱ(), rule).render();
                }
            }
        }
    }

    public void ˊʽ() {
        if (this.ॱˌ != null && this.ͺˏ == 1 && (this.ॱˌ instanceof cip)) {
            cip o_cip = (cip) this.ॱˌ;
            if (this.ˊ != null && this.ˋʻ != null && o_cip.ॱ() != null) {
                CSSRule rule = new CSSSelector(this.ˋʻ).getRule(CSSStyleSheet.parse(this.ˊ).getRootRule());
                if (rule != null) {
                    CSSView.wrap(o_cip.ॱ(), rule).render();
                }
            }
        }
    }

    public boolean ad_() {
        if (this.ͺˎ == null || ViewCompat.ˏ(this.ͺˎ, -1)) {
            return false;
        }
        return true;
    }

    public void ˏ(BaseCardBean baseCardBean) {
        Context ॱˋ = ॱˋ();
        if (ॱˋ == null) {
            Logger.ˎ("AppListFragment", "context is null, can not show detail.");
            return;
        }
        cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
        appDetailActivityProtocol.ˏ(new Request(baseCardBean.ॱॱ(), baseCardBean.u_()));
        cjm o_cjm = new cjm("appdetail.activity", appDetailActivityProtocol);
        if (epv.ˎ(ॱˋ, djc.ˋ())) {
            o_cjm.ॱ(ॱˋ).setFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
        }
        cjk.ˎ().ˋ(ॱˋ, o_cjm);
    }

    public void ॱ(Context context, BaseDistCardBean baseDistCardBean) {
        if (context == null) {
            Logger.ˎ("AppListFragment", "activity is null, can not show noApk warning dialog");
        } else if ((baseDistCardBean.ˌ() & 2) != 0) {
            Logger.ˎ("AppListFragment", "can not launch no apk app, because button status is disabled");
        } else {
            new ebt(context, baseDistCardBean).ˊ();
        }
    }

    public void ˎ(Context context, @NonNull BaseCardBean baseCardBean) {
        if (context == null) {
            Logger.ˎ("AppListFragment", "context is null, can not show mini detail dialog");
        } else if (doo.ˊ(context)) {
            new ead(context, baseCardBean).ॱ(context);
        } else {
            Logger.ˎ("AppListFragment", "no network to show app detail.");
            evk.ˏ(context, n.ʹˊ, 0).ˋ();
        }
    }
}
